<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OpenMesh: OpenMesh/Tools/Subdivider/Uniform/MidpointT.hh Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="logo_align.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="rwth_vci_rgb.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">OpenMesh
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('a00704_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">MidpointT.hh</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &lt;OpenMesh/Core/Mesh/BaseKernel.hh&gt;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="a00716.html">OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh</a>&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &lt;OpenMesh/Core/Utils/PropertyManager.hh&gt;</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &lt;algorithm&gt;</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="keyword">namespace </span><a class="code" href="a01233.html">OpenMesh</a> {</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="keyword">namespace </span>Subdivider {</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="keyword">namespace </span>Uniform {</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> MeshType, <span class="keyword">typename</span> RealType = <span class="keywordtype">double</span>&gt;</div><div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="a03037.html">   27</a></span>&#160;<span class="keyword">class </span><a class="code" href="a03037.html">MidpointT</a> : <span class="keyword">public</span> <a class="code" href="a03057.html">SubdividerT</a>&lt;MeshType, RealType&gt;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;{</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;    <span class="keyword">typedef</span> RealType real_t;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    <span class="keyword">typedef</span> MeshType mesh_t;</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <span class="keyword">typedef</span> <a class="code" href="a03057.html">SubdividerT&lt;MeshType, RealType&gt;</a> <a class="code" href="a03057.html">parent_t</a>;</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    <span class="comment">// Inherited constructors</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <a class="code" href="a03037.html">MidpointT</a>() : parent_t() {}</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    <a class="code" href="a03037.html">MidpointT</a>(mesh_t&amp; _m) : parent_t(_m) {}</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="a03037.html#a1a452d13b99ca356c3d9c594bd4d9450">   38</a></span>&#160;    <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="a03037.html#a1a452d13b99ca356c3d9c594bd4d9450">name</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">&quot;midpoint&quot;</span>; }</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="keyword">protected</span>: <span class="comment">// SubdividerT interface</span></div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="a03037.html#a74e4b5a7a91f701b4f3eabdf5601223d">   41</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="a03037.html#a74e4b5a7a91f701b4f3eabdf5601223d">prepare</a>(mesh_t&amp; _m)</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    {</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    }</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="a03037.html#a1ab79bd545947137558decd8a7b193f6">   48</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="a03037.html#a1ab79bd545947137558decd8a7b193f6">subdivide</a>(mesh_t&amp; _m, <span class="keywordtype">size_t</span> _n, <span class="keyword">const</span> <span class="keywordtype">bool</span> _update_points = <span class="keyword">true</span>)</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    {</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        _m.request_halfedge_status();</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;        _m.request_edge_status();</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;        _m.request_vertex_status();</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        _m.request_face_status();</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        <a class="code" href="a02597.html">PropertyManager&lt;EPropHandleT&lt;typename mesh_t::VertexHandle&gt;</a>&gt; edge_midpoint(_m, <span class="stringliteral">&quot;edge_midpoint&quot;</span>);</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        <a class="code" href="a02597.html">PropertyManager&lt;VPropHandleT&lt;bool&gt;</a>&gt; is_original_vertex(_m, <span class="stringliteral">&quot;is_original_vertex&quot;</span>);</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> iteration = 0; iteration &lt; _n; ++iteration) {</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;            is_original_vertex.<a class="code" href="a02597.html#a1c7b5c7063fb137ba9552afd4a0ec77f">set_range</a>(_m.vertices_begin(), _m.vertices_end(), <span class="keyword">true</span>);</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;            <span class="comment">// Create vertices on edge midpoints</span></div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;            <span class="keywordflow">for</span> (<span class="keyword">auto</span> eh : _m.edges()) {</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;                <a class="code" href="a02241.html">VertexHandle</a> new_vh = _m.new_vertex(_m.calc_edge_midpoint(eh));</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;                edge_midpoint[eh] = new_vh;</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;                is_original_vertex[new_vh] = <span class="keyword">false</span>;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;            }</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;            <span class="comment">// Create new faces from original faces</span></div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;            <span class="keywordflow">for</span> (<span class="keyword">auto</span> fh : _m.faces()) {</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;                std::vector&lt;typename mesh_t::VertexHandle&gt; new_corners;</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;                <span class="keywordflow">for</span> (<span class="keyword">auto</span> eh : _m.fe_range(fh))</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;                    new_corners.push_back(edge_midpoint[eh]);</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;                _m.add_face(new_corners);</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;            }</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;            <span class="comment">// Create new faces from original vertices</span></div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;            <span class="keywordflow">for</span> (<span class="keyword">auto</span> vh : _m.vertices()) {</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;                <span class="keywordflow">if</span> (is_original_vertex[vh]) {</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;                    <span class="keywordflow">if</span> (!_m.is_boundary(vh)) {</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;                        std::vector&lt;typename mesh_t::VertexHandle&gt; new_corners;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;                        <span class="keywordflow">for</span> (<span class="keyword">auto</span> eh : _m.ve_range(vh))</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;                            new_corners.push_back(edge_midpoint[eh]);</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;                        std::reverse(new_corners.begin(), new_corners.end());</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;                        _m.add_face(new_corners);</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;                    }</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;                }</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;            }</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;            <span class="keywordflow">for</span> (<span class="keyword">auto</span> vh : _m.vertices())</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;                <span class="keywordflow">if</span> (is_original_vertex[vh])</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;                    _m.delete_vertex(vh);</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;            _m.garbage_collection();</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;        }</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;        _m.release_face_status();</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        _m.release_vertex_status();</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;        _m.release_edge_status();</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;        _m.release_halfedge_status();</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    }</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;</div><div class="line"><a name="l00096"></a><span class="lineno"><a class="line" href="a03037.html#a1770ca984ab87327adaff2a69e584f25">   96</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="a03037.html#a1770ca984ab87327adaff2a69e584f25">cleanup</a>(mesh_t&amp; _m)</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    {</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    }</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;};</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;} <span class="comment">// namespace Uniform</span></div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;} <span class="comment">// namespace Subdivider</span></div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;} <span class="comment">// namespace OpenMesh</span></div><div class="ttc" id="a02597_html"><div class="ttname"><a href="a02597.html">OpenMesh::PropertyManager</a></div><div class="ttdoc">This class is intended to manage the lifecycle of properties. </div><div class="ttdef"><b>Definition:</b> PropertyManager.hh:80</div></div>
<div class="ttc" id="a03037_html_a1ab79bd545947137558decd8a7b193f6"><div class="ttname"><a href="a03037.html#a1ab79bd545947137558decd8a7b193f6">OpenMesh::Subdivider::Uniform::MidpointT::subdivide</a></div><div class="ttdeci">bool subdivide(mesh_t &amp;_m, size_t _n, const bool _update_points=true)</div><div class="ttdoc">Performs one step of Midpoint subdivision. </div><div class="ttdef"><b>Definition:</b> MidpointT.hh:48</div></div>
<div class="ttc" id="a02597_html_a1c7b5c7063fb137ba9552afd4a0ec77f"><div class="ttname"><a href="a02597.html#a1c7b5c7063fb137ba9552afd4a0ec77f">OpenMesh::PropertyManager::set_range</a></div><div class="ttdeci">void set_range(HandleTypeIterator begin, HandleTypeIterator end, const PROP_VALUE &amp;value)</div><div class="ttdoc">Conveniently set the property for an entire range of values. </div><div class="ttdef"><b>Definition:</b> PropertyManager.hh:517</div></div>
<div class="ttc" id="a02241_html"><div class="ttname"><a href="a02241.html">OpenMesh::VertexHandle</a></div><div class="ttdoc">Handle for a vertex entity. </div><div class="ttdef"><b>Definition:</b> Handles.hh:120</div></div>
<div class="ttc" id="a03037_html_a74e4b5a7a91f701b4f3eabdf5601223d"><div class="ttname"><a href="a03037.html#a74e4b5a7a91f701b4f3eabdf5601223d">OpenMesh::Subdivider::Uniform::MidpointT::prepare</a></div><div class="ttdeci">bool prepare(mesh_t &amp;_m)</div><div class="ttdoc">Prepare mesh, e.g. add properties. </div><div class="ttdef"><b>Definition:</b> MidpointT.hh:41</div></div>
<div class="ttc" id="a03037_html"><div class="ttname"><a href="a03037.html">OpenMesh::Subdivider::Uniform::MidpointT</a></div><div class="ttdoc">Midpoint subdivision algorithm. </div><div class="ttdef"><b>Definition:</b> MidpointT.hh:27</div></div>
<div class="ttc" id="a03057_html"><div class="ttname"><a href="a03057.html">OpenMesh::Subdivider::Uniform::SubdividerT</a></div><div class="ttdoc">Abstract base class for uniform subdivision algorithms. </div><div class="ttdef"><b>Definition:</b> SubdividerT.hh:88</div></div>
<div class="ttc" id="a00716_html"><div class="ttname"><a href="a00716.html">SubdividerT.hh</a></div></div>
<div class="ttc" id="a01233_html"><div class="ttname"><a href="a01233.html">OpenMesh</a></div><div class="ttdoc">Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...</div><div class="ttdef"><b>Definition:</b> MeshItems.hh:59</div></div>
<div class="ttc" id="a03037_html_a1a452d13b99ca356c3d9c594bd4d9450"><div class="ttname"><a href="a03037.html#a1a452d13b99ca356c3d9c594bd4d9450">OpenMesh::Subdivider::Uniform::MidpointT::name</a></div><div class="ttdeci">const char * name() const</div><div class="ttdoc">Return name of subdivision algorithm. </div><div class="ttdef"><b>Definition:</b> MidpointT.hh:38</div></div>
<div class="ttc" id="a03037_html_a1770ca984ab87327adaff2a69e584f25"><div class="ttname"><a href="a03037.html#a1770ca984ab87327adaff2a69e584f25">OpenMesh::Subdivider::Uniform::MidpointT::cleanup</a></div><div class="ttdeci">bool cleanup(mesh_t &amp;_m)</div><div class="ttdoc">Cleanup mesh after usage, e.g. remove added properties. </div><div class="ttdef"><b>Definition:</b> MidpointT.hh:96</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<hr>
<address>
<small>
<a href="http://www.rwth-graphics.de" style="text-decoration:none;">
</a>
Project <b>OpenMesh</b>, 
&copy;&nbsp; Computer Graphics Group, RWTH Aachen.
Documentation generated using 
<a class="el" href="http://www.doxygen.org/index.html">
<b>doxygen</b>
</a>.
</small>
</address>
</body>
</html>
